package so.sao.code.service.infrastructure;

import net.bytebuddy.asm.Advice;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.*;
import org.springframework.stereotype.Component;

/**
 * Created by Administrator on 2017/10/13.
 */
@Component
public class WebContext implements ApplicationListener<ApplicationReadyEvent>, ApplicationContextAware, ApplicationEventPublisherAware {
    public static ApplicationContext context;
    public static ApplicationEventPublisher publisher;
    @Autowired
    Bootstrap bootstrap;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        context = applicationContext;
    }

    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        publisher = applicationEventPublisher;
    }


    @Override
    public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
            bootstrap.init();
    }
}
